package cn.itsource.system.service.impl;

import cn.itsource.basic.util.PageResult;
import cn.itsource.org.domain.TEmployee;
import cn.itsource.system.domain.TMenu;
import cn.itsource.system.query.TMenuQuery;
import cn.itsource.system.service.TMenuService;
import cn.itsource.system.mapper.TMenuMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 26871
* @description 针对表【t_menu】的数据库操作Service实现
* @createDate 2024-04-27 11:16:19
*/
@Service
public class TMenuServiceImpl implements TMenuService{
    @Autowired
    private TMenuMapper tMenuMapper;

    @Override
    public void insert(TMenu tMenu) {
        tMenuMapper.insert(tMenu);

    }

    @Override
    public void delete(Long id) {
        tMenuMapper.delete(id);

    }

    @Override
    public void update(TMenu tMenu) {
        tMenuMapper.update(tMenu);

    }

    @Override
    public TMenu selectById(Long id) {

        return tMenuMapper.selectById(id);
    }

    @Override
    public void save(TMenu tMenu) {
        if (tMenu.getId() == null){
            tMenuMapper.insert(tMenu);
        }else {
            tMenuMapper.update(tMenu);
        }

    }

    @Override
    public void patchDelete(List<Long> ids) {
        tMenuMapper.patchDelete(ids);

    }

    @Override
    public List<TMenu> selectAll() {

        return tMenuMapper.selectAll();
    }

    @Override
    public PageResult<TMenu> selectByQueryPage(TMenuQuery tMenuQuery) {
        Integer total = tMenuMapper.selectCount(tMenuQuery);
        List<TMenu> list = tMenuMapper.selectByQueryPage(tMenuQuery);
        System.out.println(list);
        return new PageResult<TMenu>(total,list);
    }
}
